//
// Created by fengg on 2020/5/24.
//

#include <stdlib.h>
#include <stdio.h>


#define ORDER_INCREASE       1
#define ORDER_DECREASE      -1

#define DEBUG_LEVEL_1        1
#define DEBUG_LEVEL_0        0


static int __order = ORDER_INCREASE;
static int __debug = DEBUG_LEVEL_0;

static int iNumber;


int DisplayIArray(int *lpArray,int iLower,int iUpper){
    int i;
    for (i = iLower; i <= iUpper; ++i) {
        printf("%d ",lpArray[i]);
    }
    putchar('\n');
    return 0;
}

int SetFastSortOrder(int _order){
    __order = !_order ? 1 : __order;
    return 0;
}

int __fast_sort(int *lpArray,int iLower,int iUpper){
    int     iInitUpper = iUpper,
            iInitLower = iLower,
            iAnchor;

    iAnchor = lpArray[iLower];



    if(iLower >= iUpper)
        return 0;
    while (iUpper != iLower){
        while (iUpper != iLower){
            if(__order*(lpArray[iUpper] - iAnchor) < 0){
                lpArray[iLower] = lpArray[iUpper];
                break;
            }
            --iUpper;
        }
        if(iUpper != iLower)
            ++iLower;
        while (iUpper != iLower) {
            if (__order*(lpArray[iLower] - iAnchor) > 0) {
                lpArray[iUpper] = lpArray[iLower];
                break;
            }
            ++iLower;
        }
    }
    lpArray[iLower] = iAnchor;


    __fast_sort(lpArray,iInitLower,iLower-1);
    // DisplayIArray(lpArray,0,iNumber-1);
    __fast_sort(lpArray,iLower+1,iInitUpper);

    return 0;

}

int FastSort(int *lpArray,int iNumber){
    __fast_sort(lpArray,0,iNumber-1);
    return 0;
}

void SetFastSortDebug(int i) {
    __debug = i;
}




int main(){
    int *lpArray;

    int i;
    scanf("%d",&iNumber);
    lpArray = malloc(sizeof(int)*iNumber);
    for (i = 0; i < iNumber; ++i) {
        scanf("%d",&lpArray[i]);
    }

    SetFastSortOrder(ORDER_INCREASE);
    SetFastSortDebug(DEBUG_LEVEL_1);
    FastSort(lpArray,iNumber);

    putchar('\n');
    return 0;
}

